home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1997 #3
/
Amiga Plus CD - 1997 - No. 03.iso
/
pd
/
programmierung
/
alienbreed3d2_src
/
amos
/
256lit.amos
/
256lit.amosSourceCode
next >
Wrap
AMOS Source Code
|
1997-01-31
|
7KB
|
281 lines
Screen Open 7,640,24,2,Hires : Wait Vbl : Curs Off : Flash Off : Extension_12_0380 -1
Palette $8,$FF0 : Paper 0 : Pen 1 : Ink 1 : Box 0,4 To 639,20
Reserve As Work 14,640*640+12
'Reserve As Work 13,4096
Reserve As Work 12,40960
Trap Pload "ab3:includes/shadepal.aminc",6
If Errtrap
_TEMPSCR=Screen : Screen To Front 7 : Screen 7 : Locate 1,1 : Print Space$(78);
Locate 1,1 : Centre "Unable to load 'ab3:includes/shadepal.aminc'"
Screen _TEMPSCR
Wait Key
Edit
End If
Screen Open 0,640,640,32,Lowres
Curs Off : Flash Off : Cls 0
Wait Vbl
Screen Open 1,640,640,32,Lowres
Curs Off : Flash Off : Cls 0
Wait Vbl
Screen Open 2,640,640,32,Lowres
Curs Off : Flash Off : Cls 0
Wait Vbl
Screen Open 3,640,640,32,Lowres
Curs Off : Flash Off : Cls 0
Wait Vbl
Screen Open 4,640,640,32,Lowres
Curs Off : Flash Off : Cls 0
Wait Vbl
Screen Open 5,640,32,2,Lowres
Screen Display 5,,200,,
Curs Off : Flash Off : Cls 0
Colour 1,$FFF
Dim SHIN(7)
Dim CO(63),PAL(255,2),PR(31),PG(31),PB(31)
Global WOF,HOF,CO(),PAL(),PR(),PG(),PB(),SHIN(),JUSTPAL
Trap Bload "ab3:includes/256pal",Start(14)
If Errtrap
_TEMPSCR=Screen : Screen To Front 7 : Screen 7 : Locate 1,1 : Print Space$(78);
Locate 1,1 : Centre "Unable to load 'ab3:includes/256pal'"
Screen _TEMPSCR
Wait Key : Edit
End If
S=Start(14)
For A=0 To 255
PAL(A,0)=Deek(S) : Add S,2
PAL(A,1)=Deek(S) : Add S,2
PAL(A,2)=Deek(S) : Add S,2
Next
Dim RM(48)
T=0
For A=0 To 6
Read A$
For B=1 To 7
C=Asc(Mid$(A$,B,1))
If C>=65 Then C=C-65 Else C=(C-48)+26
RM(T)=C
Add T,1
Next
Next
Data "BCAAAEF"
Data "GBCDEFK"
Data "LGHIJKR"
Data "LMNOPQR"
Data "LSTUVWR"
Data "SXYZ01W"
Data "XY22201"
Repeat
F$=Fsel$("ab3:hqn/","","Load Object Graphics")
If F$="" Then End
' Load Iff F$,0
F$=F$-".dat"
F$=F$-".wad"
F$=F$-".pal"
F$=F$-".ptr"
F$=F$-".HQN"
F$=F$-".top"
F$=F$-".bot"
F$=F$-".lft"
F$=F$-".rgt"
Screen 0
Trap Load Iff(F$+".top")
_CHECKERR[F$+".top"]
Screen 1
Load Iff(F$+".bot")
_CHECKERR[F$+".top"]
Screen 2
Load Iff(F$+".lft")
_CHECKERR[F$+".top"]
Screen 3
Load Iff(F$+".rgt")
_CHECKERR[F$+".top"]
Screen 4
Load Iff(F$+".cmp")
_CHECKERR[F$+".top"]
Trap Bload F$+".cmp",Start(14)
_CHECKERR[F$+".cmp"]
S=Hunt(Start(14) To Start(14)+10000,"CMAP")+8
For A=0 To 31
PR(A)=Peek(S) : Add S,1
PG(A)=Peek(S) : Add S,1
PB(A)=Peek(S) : Add S,1
Next
For A=0 To 31 : CO(A)=Colour(A)
Next
Screen 5
Screen To Front 5
Screen To Front 7 : Screen 7 : Locate 1,1 : Print Space$(78);
Locate 1,1 : Centre "Just regenerate palette? (Y/N)"
Repeat
A$=Upper$(Inkey$)
Multi Wait
Until Instr("YN",A$)
If A$="Y" Then JUSTPAL=1 Else JUSTPAL=0
If JUSTPAL=0
Locate 1,1 : Print Space$(78); : Locate 1,1 : Input "Screen Width: ";WOS
Locate 1,1 : Print Space$(78); : Locate 1,1 : Input "Number of frames: ";NOF
Locate 1,1 : Print Space$(78); : Locate 1,1 : Input "Width of each frame: ";WOF
Locate 1,1 : Print Space$(78); : Locate 1,1 : Input "Height of each frame: ";HOF
End If
' For A=1 To 7
' Screen 4
' For B=0 To 7
' If B<>A Then Colour B,0 Else Colour B,CO(B)
' Next
' Screen 5
' Input "Shininess of colour (0-16): ";SHIN(A)
' Next
Screen 4
For A=0 To 7 : Colour A,CO(A) : Next
Screen 5
Cls 0
If JUSTPAL=0
Screen 7 : Locate 1,1 : Print Space$(78); : Locate 1,1
Centre "Creating lightmap..."
X=0 : Y=0
Z=Start(14)+6
For A=0 To NOF-1
For Q=0 To WOF-1
For W=0 To HOF-1
Screen 0 : CT= Extension_12_044C(Q+X,W+Y)/9
Screen 1 : CB= Extension_12_044C(Q+X,W+Y)/9
Screen 2 : CL= Extension_12_044C(Q+X,W+Y)
Screen 3 : CR= Extension_12_044C(Q+X,W+Y)
CL=CL/9 : CR=CR/9
Screen 4 : CC= Extension_12_044C(Q+X,W+Y)
If CC<>0
' Add CT,-1
' Add CB,-1
' Add CL,-1
' Add CR,-1
C=RM((3+CB-CT)*7+3+CR-CL)
Else
C=0
End If
Poke Z,(C*8)+CC
Add Z,1
Extension_12_036E Q+X,W+Y,0
Next
Next
X=X+WOF : If X+WOF>WOS : X=0 : Add Y,HOF : End If
Next
End If
F$=Fsel$("ab3:includes/","","Save raw data file")
If F$="" Then End
PSAVE[F$,NOF]
Screen 7
Locate 1,1 : Print Space$(78);
Locate 1,1 : Centre "All done, press any key to continue"
Wait Key
Locate 1,1 : Print Space$(78);
Locate 1,1 : Centre "Press return, or select cancel to quit"
Until 0
Edit
Procedure PSAVE[M$,NO]
If JUSTPAL=0
L=(NO*WOF*HOF)-1
'
T=0
P=Start(12)
'
S=Start(14)
Doke S,NO
Doke S+2,WOF
Doke S+4,HOF
Add S,6
Add S,L
Trap Bsave M$+".HQN",Start(14) To S
If Errtrap
_TEMPSCR=Screen : Screen 7 : Locate 1,1 : Print Space$(78);
Locate 1,1 : Centre "Unable to save "+M$+".HQN"
Screen _TEMPSCR
Wait Key : Edit
End If
End If
N=Start(12)+32*8*4
Loke Start(6),Varptr(PAL(0,0))
Loke Start(6)+4,Varptr(PR(0))
Loke Start(6)+8,Varptr(PG(0))
Loke Start(6)+12,Varptr(PB(0))
Loke Start(6)+16,Start(12)
_TEMPSCR=Screen : Screen 7 : Locate 1,1 : Print Space$(78);
Locate 1,1 : Centre "Calculating palette, this may take some time..."
Screen _TEMPSCR
Call Start(6)+20
' For PA=0 To 3
' For A=0 To 31
' V=32-A
' For Q=0 To 7
' R=PR(Q+PA*8) : G=PG(Q+PA*8) : B=PB(Q+PA*8)
' If A>=SHIN(Q)
' R=(R*(V-SHIN(Q)))/(32-SHIN(Q))
' G=(G*(V-SHIN(Q)))/(32-SHIN(Q))
' B=(B*(V-SHIN(Q)))/(32-SHIN(Q))
' Else
' L=V-(32-SHIN(Q))
' R=Min(255,R+L*5)
' G=Min(255,G+L*5)
' B=Min(255,B+L*5)
' End If
' DQ=10000000
' TC=0
' For Z=0 To 255
' DR=(R-R(Z))^2
' DG=Abs(G-G(Z))^2
' DB=Abs(B-B(Z))^2
'
' ND=(DR*3)+(DG*3)+(DB*3)
' If ND<DQ Then DQ=ND : TC=Z
' Next
'
' Poke N,TC
' Add N,1
' Next
' Next
' Next
Trap Bsave M$+".256pal",Start(12) To N
If Errtrap
_TEMPSCR=Screen : Screen 7 : Locate 1,1 : Print Space$(78);
Locate 1,1 : Centre "Unable to save "+M$+".256pal"
Screen _TEMPSCR
Wait Key
Edit
End If
End Proc
'
Procedure _CHECKERR[A$]
If Errtrap
_TEMPSCR=Screen : Screen To Front 7 : Screen 7 : Locate 1,1 : Print Space$(78);
Locate 1,1 : Centre "Unable to load "+F$
Screen _TEMPSCR
Wait Key : Edit
End If
End Proc